{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
        <!--<div id="tab_demo" class="HuiTab" style="margin-top: 0px; position: relative;">-->
            <!--<div class="tabBar clearfix">-->
                <!--<span class="current" onclick="window.location.href='javascript:;'">运费规则</span>-->
                <!--<span onclick="window.location.href='{:url(\'express/express_rules_add\')}'">添加运费规则</span>-->
            <!--</div>-->
        <!--</div>-->
        <div id="tab_demo" class="HuiTab" style="margin-top: 0px; position: relative;">
            <div class="tabBar clearfix">
                <span class="current"  >运费规则</span>
                <div class="l n_tab_add"><a href="javascript:;"
                                            onclick="window.location.href='{:url(\'express/express_rules_add\')}'"><i
                        class="Hui-iconfont">&#xe600;</i> 添加规则</a></div>
            </div>
        </div>
        <table class="table table-border table-bordered table-hover table-bg">
            <thead>
            <!--<tr>-->
                <!--<th scope="col" colspan="9">物流公司列表</th>-->
            <!--</tr>-->
            <tr class="text-c">
                <th>规则名称</th>
                <th>是否默认</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr class="text-c">
                <td>{$vo['name']}</td>
                <td>
                    {if $vo['default']==1}
                    <span class="label label-primary radius">默认</span>
                    {else}
                    <span class="label label-default radius" onclick="is_default('{$vo.id}')">设置</span>
                    {/if}
                </td>
                <td>
                    <a title="编辑" href="javascript:;" onclick="window.location.href='{:url('express/express_rules_add')}&id={$vo.id}'" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                   <a title="删除" href="javascript:;" onclick="express_del(this,'{$vo.id}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$page}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    var flag = false;//防止重复提交
    function is_default(id){
        if(flag){
            return false;
        }
        flag=true;
        layer.confirm('确认要设置默认吗？',function(index){
            //此处请求后台程序
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('express/set_default')}",
                data : {
                    "id" : id
                },
                success : function(data) {
                    if (data > 0) {
                        layer.msg('操作成功',{icon:1,time:1000},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg('操作失败', {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
    /*物流-编辑*/
    function express_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*物流-删除*/
    function express_del(obj,id){
        if(flag){
            return false;
        }
        flag=true;
        layer.confirm('确认要删除吗？',function(index){
            //此处请求后台程序
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('express/express_del')}",
                data : {
                    "id" : id
                },
                success : function(data) {
                    if (data > 0) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }else{
                        layer.msg('操作失败', {icon: 2, time: 1000});
                    }
                    flag=false;
                }
            })
        });
    }
</script>
{/block}